#include "dbusemit.h"
#include "ui_dbusemit.h"

#include "notify_adaptor.h"
#include "notify_interface.h"

#include "keyboard_adaptor.h"
#include "keyboard_interface.h"

Dbusemit::Dbusemit(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::Dbusemit)
{
    ui->setupUi(this);
    this->setFixedSize(width(), height());

/*    new NotifyAdaptor(this);
    QDBusConnection::sessionBus().registerObject("/", this);
    com::opendesk::notify *iface;
    iface = new com::opendesk::notify(QString(), QString(),QDBusConnection::sessionBus(),this);*/

    new KeyboardAdaptor(this);
    QDBusConnection::sessionBus().registerObject("/", this);
    com::opendesk::keyboard *kface;
    kface = new com::opendesk::keyboard(QString(), QString(),QDBusConnection::sessionBus(),this);

    connect(kface, SIGNAL(show(int)),this, SLOT(keyboardShow(int)));


    connect(ui->SndMsg, SIGNAL(clicked()), this, SLOT(sendMessage()));
    connect(ui->SndCll, SIGNAL(clicked()), this, SLOT(sendCall()));
    connect(ui->BttSet, SIGNAL(clicked()), this, SLOT(setBattery()));
}

Dbusemit::~Dbusemit()
{
    delete ui;
}

void Dbusemit::sendMessage(){
    QDBusMessage msg = QDBusMessage::createSignal("/", "com.opendesk.notify", "message");
    msg << ui->FromMsg->text() << ui->MsgMsg->text();
    QDBusConnection::sessionBus().send(msg);
    //messageLineEdit->setText(QString());
}

void Dbusemit::sendCall(){
    QDBusMessage msg = QDBusMessage::createSignal("/", "com.opendesk.notify", "call");
    msg << ui->FromCll->text();
    QDBusConnection::sessionBus().send(msg);
}

void Dbusemit::setBattery(){
    QDBusMessage msg = QDBusMessage::createSignal("/", "com.opendesk.notify", "battery");
    msg << ui->BttChg->isChecked() << ui->BttLev->value();
    QDBusConnection::sessionBus().send(msg);
}

void Dbusemit::sendAlert(){
    /*QDBusMessage msg = QDBusMessage::createSignal("/", "com.opendesk.notify", "battery");
    msg << ui->BttChg->isChecked() << ui->BttLev->value();
    QDBusConnection::sessionBus().send(msg);*/
}
void Dbusemit::keyboardShow(int type) {
}
